<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="js/jquery-1.4.2.min.js"></script>
<script src="js/jquery-1.11.1.min_044d0927.js"></script>
<script src="js/jquery-1.8.2.min.js"></script>
<script>
    $(function () {
        var zong=0;
        var prices=0;
        gwc()
        function gwc() {
            $.post("news/gouwuche",{},function (data) {

                $(".cars").empty()
                $.each(data.list,function (index,news) {
                    // var sid=news.id;
                    var num=data.num;
                    zong+=news.num
                    prices+=news.num*news.price
                    // zong+=data.num[sid]
                    // prices+=(data.num[sid])*news.price
                    $(".car_t").find("span").html(zong)
                    $(".price_sum").find("span").html(prices)
                    $(".car_bg").find(".cars").append(
                        "<li>\n" +
                        "<div class=\"img\"><a href=\"javascripr:;\"><img src='../../files/"+news.filename+"' width=\"58\" height=\"58\"/></a></div>\n" +
                        "<div class=\"name\"><a href=\"javascripr:;\">"+news.name+"</a></div>\n" +
                        "<div class=\"price\"><font color=\"#ff4e00\">￥"+news.price+"</font> X"+news.num+"</div>\n" +
                        "</li>"
                    )
                })
                console.log(data)
            })
        }
        $(".s_btn").click(function () {
            var c=$(".s_ipt").val()
            var context=escape(c)
            location.href="http://localhost:7777/sp.html?context="+context;
        })
        $(".gwcJS").click(function () {

            if (prices==0){
                alert("没有商品被加入购物车，请返回加入购物车后再做此操作！")
            }else {
                location.href="http://localhost:7777/BuyCar.html";
            }
        })
    })
</script>
<body>
<div class="logo"><a href="Index.html"><img src="images/rng.png"/></a></div>
<div class="search">
    <form>
        <input type="text" value="" class="s_ipt"/>
        <input type="button" value="搜索" class="s_btn"/>
    </form>
    <span class="fl"><a href="#">咖啡</a><a href="#">iphone 6S</a><a href="#">新鲜美食</a><a href="#">蛋糕</a><a
            href="#">日用品</a><a href="#">连衣裙</a></span>
</div>
<div class="i_car">
    <div class="car_t">购物车 [ <span>0</span> ]</div>
    <div class="car_bg">
        <!--Begin 购物车未登录 Begin-->
        <div class="un_login" style="display: none">还未登录！<a href="Login.html" style="color:#ff4e00;">马上登录</a> 查看购物车！</div>
        <!--End 购物车未登录 End-->
        <!--Begin 购物车已登录 Begin-->
        <ul class="cars" style="display: none"  >

        </ul>
        <div class="price_sum gw" style="display: none">共计&nbsp; <font color="#ff4e00">￥</font><span>0</span></div>
        <div class="price_a gw" style="display: none"><a class="gwcJS" href="javascript:;">去购物车结算</a></div>
        <!--End 购物车已登录 End-->
    </div>
</div>
</body>
</html>